package com.zyx.thread;

public class MyThread01 extends Thread{
    private boolean stopped;

    public MyThread01() {
    }

    public MyThread01(String name) {
        super(name);
    }

    @Override
    public void run() {
        int i=0;
        for(;;){//无限循环
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(this.getName()+"-----------------"+i++);
            //判断线程是否终止
            if(stopped){
                break;
            }
        }
    }

    public boolean isStopped() {
        return stopped;
    }

    public void setStopped(boolean stopped) {
        this.stopped = stopped;
    }
}
